import sys
import string


def getDigit(n, k):
    n = int(n)
    mask = (10**(k-1))
    n //= mask
    d = n % 10
    return d


def isShuiXianHuaNumber(x):
    n = int(x)
    if n != x:
        print('Only integers are suitable!', flush=True, file=sys.stderr)
        return False
    st = str(n)
    le = len(st)
    summary = 0
    for i in range(1, le + 1):
        d = getDigit(n, i)
        e = d ** le
        summary += e
    if summary == n:
        return True
    else:
        return False


# print(isShuiXianHuaNumber(153))

for i in range(100, 10001):
    if isShuiXianHuaNumber(i):
        print(i, end=', ')
print(flush=True)

arr = [str(x) for x in range(100, 1001) if isShuiXianHuaNumber(x)]
print(', '.join(arr))

print(flush=True)
